--- src/main.c.orig	Sat Aug 30 12:27:41 2008
+++ src/main.c	Thu May 15 16:32:39 2014

Fix broken use of the old squid-2.5 helper protocol, see
http://bugs.squid-cache.org/show_bug.cgi?id=3978#c3

@@ -175,7 +175,7 @@ int main(argc, argv, envp)
 	sgReloadConfig();
       }
       if(failsafe_mode) {
-	puts("");
+	puts("ERR message=\"squidGuard failsafe mode\"");
 	fflush(stdout);
 	if(sig_hup){
           sgReloadConfig();
@@ -184,7 +184,7 @@ int main(argc, argv, envp)
       }
       if(parseLine(buf,&squidInfo) != 1){
 	sgLogError("Error parsing squid line: %s",buf);
-	puts("");
+	puts("BH message=\"squidGuard error parsing squid line\"");
       }
         else {
 	src = Source;
@@ -196,14 +196,14 @@ int main(argc, argv, envp)
 	  acl = sgAclCheckSource(src);
 	  if((redirect = sgAclAccess(src,acl,&squidInfo)) == NULL){
 	    if(src == NULL || src->cont_search == 0){
-	      puts(""); 
+	      puts("ERR");
 	      break;
 	    } else
 	      if(src->next != NULL){
 		src = src->next;
 		continue;
 	      } else {
-		puts("");
+		puts("ERR");
 		break;
 	      }
 	  } else {
@@ -215,9 +215,10 @@ int main(argc, argv, envp)
 	      squidInfo.ident[0] = '-';
 	      squidInfo.ident[1] = '\0';
 	    }
-	    fprintf(stdout,"%s %s/%s %s %s\n",redirect,squidInfo.src,
-		    squidInfo.srcDomain,squidInfo.ident,
-		    squidInfo.method);
+	    if (isdigit(redirect[0]) && isdigit(redirect[1]) && isdigit(redirect[2]) && redirect[3]==':') {
+	      fprintf(stdout,"OK status=%c%c%c url=\"%s\"\n", redirect[0], redirect[1], redirect[2], &redirect[4]);
+	    } else
+	      fprintf(stdout,"OK rewrite-url=\"%s\"\n",redirect);
             /* sgLogError("%s %s/%s %s %s\n",redirect,squidInfo.src,squidInfo.srcDomain,squidInfo.ident,squidInfo.method);  */
 	    break;
 	  }
